package com.jason.www.dao;

import com.jason.www.domain.RolesPermissions;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface RolesPermissionsMapper {
    @Delete({
        "delete from roles_permissions",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into roles_permissions (id, roles_id, ",
        "permissions_id)",
        "values (#{id,jdbcType=BIGINT}, #{rolesId,jdbcType=BIGINT}, ",
        "#{permissionsId,jdbcType=BIGINT})"
    })
    int insert(RolesPermissions record);

    @InsertProvider(type=RolesPermissionsSqlProvider.class, method="insertSelective")
    int insertSelective(RolesPermissions record);

    @Select({
        "select",
        "id, roles_id, permissions_id",
        "from roles_permissions",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="roles_id", property="rolesId", jdbcType=JdbcType.BIGINT),
        @Result(column="permissions_id", property="permissionsId", jdbcType=JdbcType.BIGINT)
    })
    RolesPermissions selectByPrimaryKey(Long id);

    @UpdateProvider(type=RolesPermissionsSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(RolesPermissions record);

    @Update({
        "update roles_permissions",
        "set roles_id = #{rolesId,jdbcType=BIGINT},",
          "permissions_id = #{permissionsId,jdbcType=BIGINT}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(RolesPermissions record);
}